package org.txazo.blog.commons.mail;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

import org.springframework.core.io.FileSystemResource;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;

/**
 * 密码找回邮件
 * 
 * @author Tu XiaoZhou
 * @since 2013-08-12
 */
public class PasswordRetrieveMail implements Mail {

	/** 发送密码找回邮件 */
	@Override
	public void sendMail(JavaMailSender sender, String to)
			throws MessagingException {
		MimeMessage message = sender.createMimeMessage();
		MimeMessageHelper helper = new MimeMessageHelper(message, true, "UTF-8");
		helper.setTo(to);
		helper.setFrom("784990655@qq.com");
		helper.setSubject("密码找回邮件");

		helper.setText(
				"<html><body>密码找回<br />"
						+ "<a href='http://www.baidu.com'>百度</a>"
						+ "<a href='http://www.baidu.com'><img src='cid:logo' /></a></body></html>",
				true);

		helper.addInline("logo",
				new FileSystemResource("D://MyPhoto/360_1.jpg"));
		helper.addAttachment("360.jpg", new FileSystemResource(
				"D://MyPhoto/360_2.jpg"));

		sender.send(message);
	}

}